package com.example.administrator.printoutindemo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;


public class StoreListInventoryAdapter extends BaseAdapter{

	private Context mContext = null;
	private List<Inventory> li = null;
	private LayoutInflater mInflater = null;

	private class ViewHolder {
		TextView s_list_txt;
	}
	private ViewHolder holder = null;

	public StoreListInventoryAdapter(Context mContext) {
		this.mContext = mContext;
	}

	public void setList(List<Inventory> li) {
		this.li = li;
		this.mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		return li.size();
	}
	@Override
	public Object getItem(int position) {
		return li.get(position);
	}
	@Override
	public long getItemId(int position) {
		return position;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		if (null == convertView) {
			holder = new ViewHolder();

			convertView = mInflater.inflate(R.layout.store_adapter_inventory, null);

			holder.s_list_txt = (TextView) convertView
					.findViewById(R.id.s_list_txt);



			convertView.setTag(holder);
		}
		else {
			holder = (ViewHolder) convertView.getTag();
		}

		if (null != this.li) {

			Inventory o = li.get(position);

			holder.s_list_txt.setText("物料描述："+o.get_material()+ " "+o.get_nums() + "  "+ o.get_unit()
					+ "\n项目名称："+o.get_projectname() + "  仓库："+o.get_sname());

		}

		return convertView;
	}


}